package com.zs.leymovie.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by Administrator on 2015/7/20 0020.
 * 简单封装：继承自BaseAdapter，使用时可直接继承
 */
public abstract class AppAdapter<T> extends BaseAdapter {
    public List<T> list ;
    public Context context;
    public LayoutInflater inflater;
    public AppAdapter(List<T> list, Context context) {
        this.list = list;
        this.context = context;
        this.inflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return list != null && list.size()>0 ?list.size():0;
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getItemView(position,convertView,parent);
    }

    public abstract View getItemView(int position, View convertView, ViewGroup parent);
}
